package com.ywj.demo01_concurrent_porblem;

import org.openjdk.jcstress.infra.results.I_Result;

//@JCStressTest     //用并发压缩工具jcstress 测试类方法
//@Outcome(id = {"1", "4"}, expect = Expect.ACCEPTABLE, desc = "ok")    //@Outcome 对输出结果进行处理， 1 4 打印ok
//@Outcome(id = "0", expect = Expect.ACCEPTABLE_INTERESTING, desc = "danger")
//@State
public class TestOrdering {
    int num = 0;
    boolean ready = false;

    //线程1执行的代码
    //@Actor   //@Actor 表示有多个线程来操作这两个方法
    public void actor1(I_Result r) {
        if (ready) {
            r.r1 = num + num;
        } else {
            r.r1 = 1;
        }
    }

    //线程2执行的代码  对两个变量进行修改
    //@Actor
    public void actor2(I_Result r) {
        num = 2;
        ready = true;
    }
}
